package spark.example

import org.apache.spark._
import SparkContext._

object Test_aggregateByKey {
	def main(args: Array[String]) {
		val conf = new SparkConf().setAppName("Test_aggregateByKey")
		val sc = new SparkContext(conf)
		var data = sc.parallelize(List((1,3),(1,2),(1,4),(2,5),(3,6),(2,3),(1,5)))
		data.aggregateByKey(1)(seq,comb).collect().foreach(println(_))
		
	}
	def seq(a:Int, b:Int) : Int = {
		println("seq: " + a + "\t" + b)
		math.max(a,b)
	}
	
	def comb(a:Int,b:Int) : Int = {
		println("comb: " + a + "\t" + b)
		a + b
	}
}
